// import Vue from 'vue'
import router from './index.js'
//白名单
const whileList = ['/login']
router.beforeEach((to, from, next) => {
  //console.log(to,from);
  //to   即将要进入的目标 路由对象
  //from   当前导航正要离开的路由
  if (whileList.indexOf(to.path) !== -1) {
    next()
  } else {
    const token = window.sessionStorage.getItem('token')
    if (token) {
      next()
    } else {
      next('/login')
    }
  }
})
